figure(1);
x=-pi:pi;
y=sin(x);
new_x=-pi:0.1:pi;
p1=pchip(x,y,new_x);%%p是通过Hermite插值法模拟出来的对应new_x的纵坐标
p2=spline(x,y,new_x);
plot(x,y,'r-',new_x,p1,'b.',new_x,p2,'g*');

legend('样本点','三次埃尔米特插值','三次样条插值','Location','southeast');

figure(2);
year=2009:2018;
population=[133126,133770,134413,135069,135738,136427,137122,137866,138639, 139538];
p1=pchip(year,population,2019:2023);
p2=spline(year,population,2019:2023);
plot(year,population,'r-',2019:2023,p1,'b.',2019:2023,p2,'g*');
legend('样本点','三次埃尔米特插值预测','三次样条插值预测','Location','SouthEast')
